<?php
/**
 * Created by PhpStorm.
 * User: lz
 * Date: 2017/8/13
 * Time: 22:37
 */

namespace app\common\service;

//加载资源文件
class StaticService
{
    /**
     * @param $path
     * @param $depend
     */
    public static function includeAppJsStatic($path, $depend)
    {
        self::includeAppStatic("js", $path, $depend);
    }

    /**
     * @param $path
     * @param $depend
     */
    public static function includeAppCssStatic($path, $depend)
    {
        self::includeAppStatic("css", $path, $depend);
    }

    /**
     *
     */
    public static function includeAppStatic($type, $path, $depend)
    {
        $release_version = defined("RELEASE_VERSION") ? RELEASE_VERSION : time();
        $path = $path . "?ver={$release_version}";
        if ($type == "js") {
            \yii::$app->getView()->registerJsFile($path, ["depends" => $depend]);
        } else {
            \yii::$app->getView()->registerCssFile($path, ["depends" => $depend]);
        }

    }
}